package io.renren.modules.business.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.business.entity.BondRecordEntity;
import io.renren.modules.business.service.BondRecordService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 债券记录表
 *
 * @author weifengbo
 * @email 931327348@qq.com
 * @date 2020-03-21 15:10:50
 */
@RestController
@RequestMapping("business/bondrecord")
public class BondRecordController {
    @Autowired
    private BondRecordService bondRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:bondrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bondRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:bondrecord:info")
    public R info(@PathVariable("id") Integer id){
        BondRecordEntity bondRecord = bondRecordService.getById(id);

        return R.ok().put("bondRecord", bondRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:bondrecord:save")
    public R save(@RequestBody BondRecordEntity bondRecord){
        bondRecordService.save(bondRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:bondrecord:update")
    public R update(@RequestBody BondRecordEntity bondRecord){
        ValidatorUtils.validateEntity(bondRecord);
        bondRecordService.updateById(bondRecord);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:bondrecord:delete")
    public R delete(@RequestBody Integer[] ids){
        bondRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
